package com.ss.utils;

import java.io.*;

/**
 * 用于将mysql的插入语句转换为符合oracle语法的插入语句
 * 手动替换流程：
 * 0、先使用大文件编辑软件PilotEdit，将原始文件掐头去尾，处理成纯粹的数据插入语句
 * 1、替换insert部分，添加上属性名
 * 2、将批量插入改为单条插入
 * 3、文件切割
 * 4、删除临时文件
 */
public class MysqlToOracleInsertSQLTools {
    public static void main(String[] args) {
        // =============充电订单============
//        String inputFilePathOrder = "D:\\DFZT\\天津项目\\车联网相关数据\\car_boss_order.sql";
//        splitOrder(inputFilePathOrder,2000000);
//        // =============充电过程============
//        String inputFilePathGunRun = "D:\\DFZT\\天津项目\\车联网相关数据\\car_boss_run\\car_boss_run.sql";
//        splitGunRun(inputFilePathGunRun,8000000);
        // =============故障信息============
        String inputFilePathAlarm = "D:\\DFZT\\天津项目\\车联网相关数据\\dc_pile_alarm_info\\dc_pile_alarm_info.sql";
        splitAlarm(inputFilePathAlarm,2000000);
    }

    // 处理订单数据脚本
    public static void splitOrder(String inputFilePath,int linesPerFile){
        // 创建临时文件夹
        String tmpFolderPath = System.getProperty("user.home") + System.getProperty("file.separator") + "Desktop" + System.getProperty("file.separator") + "tmp";
        File folder = new File(tmpFolderPath);
        if(!folder.exists()){
            folder.mkdirs();
            System.out.println("已成功在桌面创建tmp临时文件夹！");
        }else {
            System.out.println("tmp临时文件夹已存在！");
        }
        // 替换1
        String tempFilePath01 = tmpFolderPath + "\\car_boss_order_tmp01.sql";
        String targetText01 = "INSERT INTO `dc_car_order` VALUES";
        String replacementText01 = "INSERT INTO \"COLLECT_DC_CAR_ORDER\" (\"CAR_ORDER_ID\", \"ORDER_ID\", \"USER_CODE\", \"PHONE\", \"CARD_CODE\", \"PHY_CARD_NO\", \"CARD_RANDOM\", \"TRADE_FLOW_CODE\", \"TRADE_TIME\", \"ORDER_STAKE_CHECK_ID\", \"THIRD_TRADE_CODE\", \"ORDER_CONSUME_TYPE_FLAG\", \"ORDER_CONSUME_TYPE_STR\", \"STAKE_CODE\", \"STAKE_NAME\", \"STATION_CODE\", \"STATION_NAME\", \"ORDER_CREATE_TIME\", \"ORDER_STATE_FLAG\", \"ORDER_STATE_STR\", \"TOTAL_ELECTRICITY\", \"TOTAL_ELEC_AMOUNT\", \"TOTAL_SERVICE_AMOUNT\", \"TOTAL_AMOUNT\", \"SERVICE_AMOUNT\", \"DISCOUNT_AMOUNT\", \"ACT_AMOUNT\", \"ACTIVITY_CODE\", \"ORDER_START_TIME\", \"ORDER_END_TIME\", \"IS_INVOICE_FLAG\", \"INVOICE_RECORD_ID\", \"INVOICE_STR\", \"RUN_ELECTY\", \"TOTAL_STVALUE\", \"TOTAL_SPVALUE\", \"REQUEST_FREEZE_AMOUNT\", \"REQUEST_ELECTY\", \"R_CARD_FORZEN_AMOUNT\", \"R_CARD_PAY_AMOUNT\", \"ELEC_ACCT_FROZEN_AMOUNT\", \"FIN_CLEARING_ID\", \"FIN_CLEARING_MONTH\", \"FIN_OU_CODE\", \"ACCEPT_TIME\", \"PAY_CODE\", \"ORDER_CHANNEL_FLAG\", \"ORDER_SOURCE_STR\", \"PAY_MODE_FLAG\", \"PAY_MODE_STR\", \"PAID_TIME\", \"ACT_SERVICE_AMOUNT\", \"SERVICE_DISCOUNTS_AMOUNT\", \"ACT_ELEC_AMOUNT\", \"SPOT_ELECTRIC\", \"PEAK_ELECTRIC\", \"FLAT_ELECTRIC\", \"VALLEY_ELECTRIC\", \"BF_CARD_EWBALANCE\", \"AF_CARD_EWBALANCE\", \"FEE_MODEL_ID\", \"MODEL_ELEC_ID\", \"MODEL_SERVICE_ID\", \"CHARGE_STOP_REASON_FLAG\", \"VIN_CODE\", \"PROVINCE_LEVEL_PROPERTY_CODE\", \"PROVINCE_LEVEL_PROPERTY_NAME\", \"CITY_LEVEL_PROPERTY_CODE\", \"CITY_LEVEL_PROPERTY_NAME\", \"UPDATE_TIME\", \"MONTH_ID\", \"DATA_OPER_TIME\", \"DATA_CREA_TIME\", \"FAULT_MARKING\", \"FAULT_NAME\", \"FAULT_LEVEL\", \"SECURITY_IMPACT\", \"STOP_REASON_NAME\", \"TCU_DISPLAY\", \"NORMAL_FLAG\", \"ABNORMAL_POINTS\", \"ABNORMAL_TYPE\", \"ABNORMAL_NAME\", \"FAULT_TIME\", \"BIZ_LICENSE_NO\", \"BUSS_TYPE\", \"ORD_TYPE\", \"BUSS_TYPE_STR\", \"CHARG_VERIC\", \"CHARGE_PORT\", \"PROVINCE_CODE\", \"CITY_CODE\", \"DT\", \"ORDER_COMMENT\", \"CONS_AMOUNT\", \"CONS_AMOUNT_ELECTRIC\", \"CONS_AMOUNT_SERVICE\", \"DISTRICT_CODE\", \"ELEC_AMOUNT\", \"ELEC_DISCOUNTS_AMOUNT\", \"ELEC_PAY_AMOUNT\", \"EQUIP_NUM\", \"EQUIPMENT_CODE\", \"EXCEPT_BIG_AMOUNT\", \"GREY_TRADE_ID\", \"IS_ADD_ORDER\", \"IS_ISSUE\", \"LINE_NUMBER\", \"MEAS_ID\", \"MANAGE_OU_CODE\", \"OCCUR_OU_CODE\", \"OPERATE_OU_CODE\", \"ORDER_CHANNEL\", \"ORDER_CHANNEL_STR\", \"ORDER_ISSUE_ID\", \"ORDER_TAG\", \"DATA_INTERFACE_RECEIVE_TIME\", \"SEARCH_KEY\", \"SUPERVISE_OU_CODE\", \"DATA_SOURCES\") VALUES";
        replaceText(inputFilePath,tempFilePath01,targetText01,replacementText01);
        // 替换2
        String inputFilePath02 = tempFilePath01;
        String tempFilePath02 = tmpFolderPath + "\\car_boss_order_tmp02.sql";
        String targetText02 = "),";
        String replacementText02 = ");\n" +
                "INSERT INTO \"COLLECT_DC_CAR_ORDER\" (\"CAR_ORDER_ID\", \"ORDER_ID\", \"USER_CODE\", \"PHONE\", \"CARD_CODE\", \"PHY_CARD_NO\", \"CARD_RANDOM\", \"TRADE_FLOW_CODE\", \"TRADE_TIME\", \"ORDER_STAKE_CHECK_ID\", \"THIRD_TRADE_CODE\", \"ORDER_CONSUME_TYPE_FLAG\", \"ORDER_CONSUME_TYPE_STR\", \"STAKE_CODE\", \"STAKE_NAME\", \"STATION_CODE\", \"STATION_NAME\", \"ORDER_CREATE_TIME\", \"ORDER_STATE_FLAG\", \"ORDER_STATE_STR\", \"TOTAL_ELECTRICITY\", \"TOTAL_ELEC_AMOUNT\", \"TOTAL_SERVICE_AMOUNT\", \"TOTAL_AMOUNT\", \"SERVICE_AMOUNT\", \"DISCOUNT_AMOUNT\", \"ACT_AMOUNT\", \"ACTIVITY_CODE\", \"ORDER_START_TIME\", \"ORDER_END_TIME\", \"IS_INVOICE_FLAG\", \"INVOICE_RECORD_ID\", \"INVOICE_STR\", \"RUN_ELECTY\", \"TOTAL_STVALUE\", \"TOTAL_SPVALUE\", \"REQUEST_FREEZE_AMOUNT\", \"REQUEST_ELECTY\", \"R_CARD_FORZEN_AMOUNT\", \"R_CARD_PAY_AMOUNT\", \"ELEC_ACCT_FROZEN_AMOUNT\", \"FIN_CLEARING_ID\", \"FIN_CLEARING_MONTH\", \"FIN_OU_CODE\", \"ACCEPT_TIME\", \"PAY_CODE\", \"ORDER_CHANNEL_FLAG\", \"ORDER_SOURCE_STR\", \"PAY_MODE_FLAG\", \"PAY_MODE_STR\", \"PAID_TIME\", \"ACT_SERVICE_AMOUNT\", \"SERVICE_DISCOUNTS_AMOUNT\", \"ACT_ELEC_AMOUNT\", \"SPOT_ELECTRIC\", \"PEAK_ELECTRIC\", \"FLAT_ELECTRIC\", \"VALLEY_ELECTRIC\", \"BF_CARD_EWBALANCE\", \"AF_CARD_EWBALANCE\", \"FEE_MODEL_ID\", \"MODEL_ELEC_ID\", \"MODEL_SERVICE_ID\", \"CHARGE_STOP_REASON_FLAG\", \"VIN_CODE\", \"PROVINCE_LEVEL_PROPERTY_CODE\", \"PROVINCE_LEVEL_PROPERTY_NAME\", \"CITY_LEVEL_PROPERTY_CODE\", \"CITY_LEVEL_PROPERTY_NAME\", \"UPDATE_TIME\", \"MONTH_ID\", \"DATA_OPER_TIME\", \"DATA_CREA_TIME\", \"FAULT_MARKING\", \"FAULT_NAME\", \"FAULT_LEVEL\", \"SECURITY_IMPACT\", \"STOP_REASON_NAME\", \"TCU_DISPLAY\", \"NORMAL_FLAG\", \"ABNORMAL_POINTS\", \"ABNORMAL_TYPE\", \"ABNORMAL_NAME\", \"FAULT_TIME\", \"BIZ_LICENSE_NO\", \"BUSS_TYPE\", \"ORD_TYPE\", \"BUSS_TYPE_STR\", \"CHARG_VERIC\", \"CHARGE_PORT\", \"PROVINCE_CODE\", \"CITY_CODE\", \"DT\", \"ORDER_COMMENT\", \"CONS_AMOUNT\", \"CONS_AMOUNT_ELECTRIC\", \"CONS_AMOUNT_SERVICE\", \"DISTRICT_CODE\", \"ELEC_AMOUNT\", \"ELEC_DISCOUNTS_AMOUNT\", \"ELEC_PAY_AMOUNT\", \"EQUIP_NUM\", \"EQUIPMENT_CODE\", \"EXCEPT_BIG_AMOUNT\", \"GREY_TRADE_ID\", \"IS_ADD_ORDER\", \"IS_ISSUE\", \"LINE_NUMBER\", \"MEAS_ID\", \"MANAGE_OU_CODE\", \"OCCUR_OU_CODE\", \"OPERATE_OU_CODE\", \"ORDER_CHANNEL\", \"ORDER_CHANNEL_STR\", \"ORDER_ISSUE_ID\", \"ORDER_TAG\", \"DATA_INTERFACE_RECEIVE_TIME\", \"SEARCH_KEY\", \"SUPERVISE_OU_CODE\", \"DATA_SOURCES\") VALUES";
        replaceText(inputFilePath02,tempFilePath02,targetText02,replacementText02);
        // 切割
        String inputFilePath03 = tempFilePath02;
        String outputDir = System.getProperty("user.home") + System.getProperty("file.separator") + "Desktop" + System.getProperty("file.separator") + "\\car_boss_order_final";
        splitFile(linesPerFile,inputFilePath03,outputDir);
        // 清理中间文件
        deleteFile(tempFilePath01);
        deleteFile(tempFilePath02);
    }

    // 处理过程数据脚本
    public static void splitGunRun(String inputFilePath,int linesPerFile){
        String tmpFolderPath = System.getProperty("user.home") + System.getProperty("file.separator") + "Desktop" + System.getProperty("file.separator") + "tmp";
        File folder = new File(tmpFolderPath);
        if(!folder.exists()){
            folder.mkdirs();
            System.out.println("已成功在桌面创建tmp临时文件夹！");
        }else {
            System.out.println("tmp临时文件夹已存在！");
        }
        // 替换1
        String tempFilePath01 = tmpFolderPath + "\\car_boss_run_tmp01.sql";
        String targetText01 = "INSERT INTO `dc_pile_gun_run` VALUES";
        String replacementText01 = "INSERT INTO \"COLLECT_DC_PILE_GUN_RUN\" (\"GUN_RUN_ID\",\"STATION_NO\",\"PILE_NO\",\"GUN_NO\",\"RUN_STATUS\",\"CURRENT_A\",\"CURRENT_B\",\"CURRENT_C\",\"ELEC_MONEY\",\"END_TIME\",\"SEVICE_MONEY\",\"SOC\",\"START_CHARGE_SEQ\",\"START_CHARGE_SEQ_STAT\",\"START_TIME\",\"SUM_PERIOD\",\"TOTAL_MONEY\",\"TOTAL_POWER\",\"VOLTAGE_A\",\"VOLTAGE_B\",\"VOLTAGE_C\",\"DATA_INTERFACE_RECEIVE_TIME\",\"DATA_OPER_TIME\") VALUES";
        replaceText(inputFilePath,tempFilePath01,targetText01,replacementText01);
        // 替换2
        String inputFilePath02 = tempFilePath01;
        String tempFilePath02 = tmpFolderPath + "\\car_boss_run_tmp02.sql";
        String targetText02 = "),";
        String replacementText02 = ");\n" +
                "INSERT INTO \"COLLECT_DC_PILE_GUN_RUN\" (\"GUN_RUN_ID\",\"STATION_NO\",\"PILE_NO\",\"GUN_NO\",\"RUN_STATUS\",\"CURRENT_A\",\"CURRENT_B\",\"CURRENT_C\",\"ELEC_MONEY\",\"END_TIME\",\"SEVICE_MONEY\",\"SOC\",\"START_CHARGE_SEQ\",\"START_CHARGE_SEQ_STAT\",\"START_TIME\",\"SUM_PERIOD\",\"TOTAL_MONEY\",\"TOTAL_POWER\",\"VOLTAGE_A\",\"VOLTAGE_B\",\"VOLTAGE_C\",\"DATA_INTERFACE_RECEIVE_TIME\",\"DATA_OPER_TIME\") VALUES";
        replaceText(inputFilePath02,tempFilePath02,targetText02,replacementText02);
        // 切割
        String inputFilePath03 = tempFilePath02;
        String outputDir = System.getProperty("user.home") + System.getProperty("file.separator") + "Desktop" + System.getProperty("file.separator") + "\\car_boss_run_final";
        splitFile(linesPerFile,inputFilePath03,outputDir);
        // 清理中间文件
        deleteFile(tempFilePath01);
        deleteFile(tempFilePath02);
    }

    // 处理故障信息脚本
    public static void splitAlarm(String inputFilePath,int linesPerFile){
        String tmpFolderPath = System.getProperty("user.home") + System.getProperty("file.separator") + "Desktop" + System.getProperty("file.separator") + "tmp";
        File folder = new File(tmpFolderPath);
        if(!folder.exists()){
            folder.mkdirs();
            System.out.println("已成功在桌面创建tmp临时文件夹！");
        }else {
            System.out.println("tmp临时文件夹已存在！");
        }
        // 替换1
        String tempFilePath01 = tmpFolderPath + "\\dc_pile_alarm_info_tmp01.sql";
        String targetText01 = "INSERT INTO `dc_pile_alarm_info` VALUES";
        String replacementText01 = "INSERT INTO \"COLLECT_DC_PILE_ALARM_INFO\" (\"UUID\", \"STATION_NO\", \"STATION_UUID\", \"STATION_NAME\", \"STAKE_NO\", \"STAKE_NAME\", \"FAULT_TYPE\", \"FAULT_START_TIME\", \"FAULT_END_TIME\", \"FAULT_DURATION\", \"FAULT_DETAIL\", \"ALARM_LEVEL\", \"ALARM_LEVEL_TITLE\", \"BUSINESS_TYPE\", \"WORK_ORDER_ID\", \"WORK_ORDER_STATE\", \"WORK_ORDER_START_TIME\", \"WORK_ORDER_PRODUCE_TIME\", \"WORK_ORDER_END_TIME\", \"WORK_ORDER_USER_ID\", \"WORK_ORDER_TIME\", \"CHARGING_TYPE\", \"TCU_VERSION\", \"VENDOR_UUID\", \"VENDOR_NAME\", \"RATED_POWER\", \"PROVINCE_LEVEL_ORG_NAME\", \"CITY_LEVEL_ORG_NAME\", \"COUNTY_COMPANY\", \"COUNTY_COMPANY_NAME\", \"PROVINCE_LEVEL_OM_NAME\", \"PROVINCE_LEVEL_PROPERTY_NAME\", \"ASSET_ORG_NO\", \"UPDATE_TIME\", \"DATA_OPER_TIME\", \"DATA_CREA_TIME\", \"AC_TAG\", \"AC_STATUS\", \"ALARM_FROM\", \"ALARM_RULE_DETAIL\", \"ALARM_RULE_RESULT\", \"ASE_AT_CHANNEL\", \"ASSESS_STATUS\", \"CHARGER_NO\", \"CITY_COMPANY\", \"CITY_COMPANY_NAME\", \"CITY_ID\", \"CITY_NAME\", \"WORK_ORDER_RECEIVE_TIME\", \"COUNTY_ID\", \"COUNTY_NAME\", \"CREATE_TIME\", \"FAULT_CLEAR_MODE\", \"FAULT_RECEIVE_CLEAR_TIME\", \"FAULT_START_MANAGE_STATUS\", \"FAULT_END_MANAGE_STATUS\", \"FAULT_START_MQ_DETAIL\", \"FAULT_END_MQ_DETAIL\", \"FAULT_MARKING\", \"FAULT_RECEIVE_TIME\", \"FAULT_STATE\", \"IS_AFFIRM\", \"IS_SPAN_DAY\", \"IS_DELETE\", \"OPERA_TIME\", \"OPERATION_TS\", \"PROVINCE_ID\", \"PROVINCE_NAME\", \"PROVINCE_COMPANY_NAME\", \"PROVINCE_COMPANY\", \"SR_TAG\", \"THIRDPARTNAR_ORG_NO\", \"WORK_STATUS\", \"DATA_INTERFACE_RECEIVE_TIME\", \"DATA_SOURCES\") VALUES";
        replaceText(inputFilePath,tempFilePath01,targetText01,replacementText01);
        // 替换2
        String inputFilePath02 = tempFilePath01;
        String tempFilePath02 = tmpFolderPath + "\\dc_pile_alarm_info_tmp02.sql";
        String targetText02 = "),";
        String replacementText02 = ");\n" +
                "INSERT INTO \"COLLECT_DC_PILE_ALARM_INFO\" (\"UUID\", \"STATION_NO\", \"STATION_UUID\", \"STATION_NAME\", \"STAKE_NO\", \"STAKE_NAME\", \"FAULT_TYPE\", \"FAULT_START_TIME\", \"FAULT_END_TIME\", \"FAULT_DURATION\", \"FAULT_DETAIL\", \"ALARM_LEVEL\", \"ALARM_LEVEL_TITLE\", \"BUSINESS_TYPE\", \"WORK_ORDER_ID\", \"WORK_ORDER_STATE\", \"WORK_ORDER_START_TIME\", \"WORK_ORDER_PRODUCE_TIME\", \"WORK_ORDER_END_TIME\", \"WORK_ORDER_USER_ID\", \"WORK_ORDER_TIME\", \"CHARGING_TYPE\", \"TCU_VERSION\", \"VENDOR_UUID\", \"VENDOR_NAME\", \"RATED_POWER\", \"PROVINCE_LEVEL_ORG_NAME\", \"CITY_LEVEL_ORG_NAME\", \"COUNTY_COMPANY\", \"COUNTY_COMPANY_NAME\", \"PROVINCE_LEVEL_OM_NAME\", \"PROVINCE_LEVEL_PROPERTY_NAME\", \"ASSET_ORG_NO\", \"UPDATE_TIME\", \"DATA_OPER_TIME\", \"DATA_CREA_TIME\", \"AC_TAG\", \"AC_STATUS\", \"ALARM_FROM\", \"ALARM_RULE_DETAIL\", \"ALARM_RULE_RESULT\", \"ASE_AT_CHANNEL\", \"ASSESS_STATUS\", \"CHARGER_NO\", \"CITY_COMPANY\", \"CITY_COMPANY_NAME\", \"CITY_ID\", \"CITY_NAME\", \"WORK_ORDER_RECEIVE_TIME\", \"COUNTY_ID\", \"COUNTY_NAME\", \"CREATE_TIME\", \"FAULT_CLEAR_MODE\", \"FAULT_RECEIVE_CLEAR_TIME\", \"FAULT_START_MANAGE_STATUS\", \"FAULT_END_MANAGE_STATUS\", \"FAULT_START_MQ_DETAIL\", \"FAULT_END_MQ_DETAIL\", \"FAULT_MARKING\", \"FAULT_RECEIVE_TIME\", \"FAULT_STATE\", \"IS_AFFIRM\", \"IS_SPAN_DAY\", \"IS_DELETE\", \"OPERA_TIME\", \"OPERATION_TS\", \"PROVINCE_ID\", \"PROVINCE_NAME\", \"PROVINCE_COMPANY_NAME\", \"PROVINCE_COMPANY\", \"SR_TAG\", \"THIRDPARTNAR_ORG_NO\", \"WORK_STATUS\", \"DATA_INTERFACE_RECEIVE_TIME\", \"DATA_SOURCES\") VALUES";
        replaceText(inputFilePath02,tempFilePath02,targetText02,replacementText02);
        // 切割
        String inputFilePath03 = tempFilePath02;
        String outputDir = System.getProperty("user.home") + System.getProperty("file.separator") + "Desktop" + System.getProperty("file.separator") + "dc_pile_alarm_info_final";
        splitFile(linesPerFile,inputFilePath03,outputDir);
        // 清理中间文件
        deleteFile(tempFilePath01);
        deleteFile(tempFilePath02);
    }

    // 文件按行进行文本替换
    public static void replaceText(String inputFilePath,String tempFilePath,String targetText,String replacementText){
        try (BufferedReader reader = new BufferedReader(new FileReader(inputFilePath));
             BufferedWriter writer = new BufferedWriter(new FileWriter(tempFilePath))) {
            int rownum = 1;

            String line;
            while ((line = reader.readLine()) != null) {
                // 进行文本替换
                line = line.replace(targetText, replacementText);
                // 写入临时文件
                writer.write(line);
                writer.newLine();
                System.out.println("第 " + rownum ++ +" 行" + "处理完成！");
            }

            System.out.println("Text replacement completed successfully.");

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    // 文件按行切割
    public static void splitFile(int linesPerFile,String inputFilePath,String outputDir){
        int fileCounter = 1;

        // 提高可用性
        File outputDirectory = new File(outputDir);
        if (!outputDirectory.exists() && !outputDirectory.mkdirs()) {
            System.err.println("Failed to create output directory: " + outputDir);
            System.exit(1);
        }

        try (BufferedReader reader = new BufferedReader(new FileReader(inputFilePath))) {
            String line;
            BufferedWriter currentWriter = null;
            int lineCount = 0;

            while ((line = reader.readLine()) != null) {
                if (lineCount == 0) {
                    System.out.println("正在写入第 "+ fileCounter + " 个文件！");
                    File outputFile = new File(outputDirectory, "part_" + fileCounter + ".sql");
                    currentWriter = new BufferedWriter(new FileWriter(outputFile));
                    fileCounter++;
                }

                currentWriter.write(line);
                currentWriter.newLine();
                lineCount++;

                if (lineCount >= linesPerFile) {
                    currentWriter.close();
                    currentWriter = null;
                    lineCount = 0;
                }
            }

            // 确保最后一个文件也被关闭（如果它存在的话）
            if (currentWriter != null) {
                currentWriter.close();
            }

            System.out.println("File splitting completed successfully.");

        } catch (IOException e) {
            System.err.println("An error occurred while splitting the file: " + e.getMessage());
            // 注意：在这里，如果currentWriter不为null，它应该已经被上面的逻辑关闭了
            // 但是，为了安全起见，你可以在catch块中添加一个额外的检查来关闭它（尽管在这个例子中不是必需的）
        }
    }

    // 删除文件
    public static void deleteFile(String filePath){
        File file = new File(filePath);
        if(file.exists() && file.isFile()){
            boolean delete = file.delete();
            if (delete){
                System.out.println("文件已成功删除:"+filePath);
            }else {
                System.out.println("文件删除失败:"+filePath);
            }
        }else {
            System.out.println("文件不存在或不是一个文件:"+filePath);
        }
    }


}
